$(document).ajaxSend(function (e,xqr,opt) {
    var user_token = localStorage.getItem("user_token");
    xqr.setRequestHeader("user_token",user_token);
});


function getUserInfo(urlStr) {
    $.ajax({
        type: "get",
        url: urlStr,
        success: function (result) {
            if (result.code == 200 && result.data != null) {
                $(".left .card h3").text(result.data.userName);
                $(".left .card a").attr("href",result.data.githubUrl);
            }
        },
        error: function (error) {
            console.log(error);
            if (error != null && error.status == 401) {
                alert("用户未登录, 即将跳转到登录界面");
                // 已经被拦截器拦截了, 未登录
                location.href = "blog_login.html";
            }
        }
    });
}

function logout() {
    // 删除Cookie, 设置Cookie为空即可
    localStorage.removeItem("user_token");
    location.href = "/blog_login.html";
}